*===============================================================================
* Do-file creates "Experimental Dataset: Violence Expectations by Treatment Sample"
* Table A13
*===============================================================================
clear
set more off


cd "~/Dropbox/VFD/REStat_Native_Files/Stata_Files"
local output "~/Dropbox/VFD/REStat_Native_Files/Stata_Files/Output"

use cadg_master_NATIVE.dta, clear

* Running regression to get right e(sample)
qui: reghdfe cash_savings violence_34 if sample_cash_outlier==0, cl(employeenumber) ab(employeenumber ym) keepsing
gen sample=1 if e(sample)


*** PANEL A -- FULL SAMPLE ***

* Column 1
reghdfe cumbalance violence_34 if sample_cash_outlier==0 & sample==1, cl(employeenumber) ab(ym) keepsing
est store col1
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "All"
estadd local monthFE "YES"
estadd local stratumFE "NO"
estadd local individFE "NO"
estadd scalar adjR2 =  e(r2_a)

* Column 2
reghdfe cumbalance violence_34 if sample_cash_outlier==0 & sample==1, cl(employeenumber) ab(ym block_final) keepsing
est store col2
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "All"
estadd local monthFE "YES"
estadd local stratumFE "YES"
estadd local individFE "NO"
estadd scalar adjR2 =  e(r2_a)

* Column 3
reghdfe cumbalance violence_34 if sample_cash_outlier==0 & sample==1, cl(employeenumber) ab(employeenumber ym) keepsing
est store col3
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "All"
estadd local monthFE "YES"
estadd local stratumFE "-"
estadd local individFE "YES"
estadd scalar adjR2 =  e(r2_a)

* Column 4
reghdfe cash_savings violence_34 if sample_cash_outlier==0 & sample==1, cl(employeenumber) ab(ym) keepsing
est store col4
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "All"
estadd local monthFE "YES"
estadd local stratumFE "NO"
estadd local individFE "NO"
estadd scalar adjR2 =  e(r2_a)

* Column 5
reghdfe cash_savings violence_34 if sample_cash_outlier==0 & sample==1, cl(employeenumber) ab(ym block_final) keepsing
est store col5
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "All"
estadd local monthFE "YES"
estadd local stratumFE "YES"
estadd local individFE "NO"
estadd scalar adjR2 =  e(r2_a)

* Column 6
reghdfe cash_savings violence_34 if sample_cash_outlier==0 & sample==1, cl(employeenumber) ab(employeenumber ym) keepsing
est store col6
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "All"
estadd local monthFE "YES"
estadd local stratumFE "-"
estadd local individFE "YES"
estadd scalar adjR2 =  e(r2_a)

esttab col1 col2 col3 col4 col5 col6 using "`output'/table_a13a.tex", cells(b(fmt(%9.2f) star) se(par fmt(%9.2f))) ///
starlevels(* .1 ** .05 *** .01) style(tex) keep(violence_34) ///
stats(samplestr in_sample_mean N_clust N adjR2 monthFE stratumFE individFE, fmt(0 2 0 0 2 0 0 0)  label("Sample" "Mean Dep Var" "\# Employees" "\# Observations" "R-Squared" "Month FE" "Strata FE" "Employee FE")) ///
label title("Experimental Dataset: Violence Expectations by Treatment Sample") replace 

*** PANEL B -- TREAT X POST ONLY ***

* Column 1
reghdfe cumbalance violence_34 if sample_cash_outlier==0 & sample==1 & treat_post==1, cl(employeenumber) ab(ym) keepsing
est store col1
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "Treat x Post"
estadd local monthFE "YES"
estadd local stratumFE "NO"
estadd local individFE "NO"
estadd scalar adjR2 =  e(r2_a)

* Column 2
reghdfe cumbalance violence_34 if sample_cash_outlier==0 & sample==1  & treat_post==1, cl(employeenumber) ab(ym block_final) keepsing
est store col2
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "Treat x Post"
estadd local monthFE "YES"
estadd local stratumFE "YES"
estadd local individFE "NO"
estadd scalar adjR2 =  e(r2_a)

* Column 3
reghdfe cumbalance violence_34 if sample_cash_outlier==0 & sample==1  & treat_post==1, cl(employeenumber) ab(employeenumber ym) keepsing
est store col3
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "Treat x Post"
estadd local monthFE "YES"
estadd local stratumFE "-"
estadd local individFE "YES"
estadd scalar adjR2 =  e(r2_a)

* Column 4
reghdfe cash_savings violence_34 if sample_cash_outlier==0 & sample==1 & treat_post==1, cl(employeenumber) ab(ym) keepsing
est store col4
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "Treat x Post"
estadd local monthFE "YES"
estadd local stratumFE "NO"
estadd local individFE "NO"
estadd scalar adjR2 =  e(r2_a)

* Column 5
reghdfe cash_savings violence_34 if sample_cash_outlier==0 & sample==1 & treat_post==1, cl(employeenumber) ab(ym block_final) keepsing
est store col5
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "Treat x Post"
estadd local monthFE "YES"
estadd local stratumFE "YES"
estadd local individFE "NO"
estadd scalar adjR2 =  e(r2_a)

* Column 6
reghdfe cash_savings violence_34 if sample_cash_outlier==0 & sample==1 & treat_post==1, cl(employeenumber) ab(employeenumber ym) keepsing
est store col6
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "Treat x Post"
estadd local monthFE "YES"
estadd local stratumFE "-"
estadd local individFE "YES"
estadd scalar adjR2 =  e(r2_a)

esttab col1 col2 col3 col4 col5 col6 using "`output'/table_a13b.tex", cells(b(fmt(%9.2f) star) se(par fmt(%9.2f))) ///
starlevels(* .1 ** .05 *** .01) style(tex) keep(violence_34) ///
stats(samplestr in_sample_mean N_clust N adjR2 monthFE stratumFE individFE, fmt(0 2 0 0 2 0 0 0)  label("Sample" "Mean Dep Var" "\# Employees" "\# Observations" "R-Squared" "Month FE" "Strata FE" "Employee FE")) ///
label title("Experimental Dataset: Violence Expectations by Treatment Sample") replace 


*** PANEL C -- CONTROL GROUP ONLY ***

* Column 1
reghdfe cumbalance violence_34 if sample_cash_outlier==0 & sample==1 & treat_final==0, cl(employeenumber) ab(ym) keepsing
est store col1
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "Control"
estadd local monthFE "YES"
estadd local stratumFE "NO"
estadd local individFE "NO"
estadd scalar adjR2 =  e(r2_a)

* Column 2
reghdfe cumbalance violence_34 if sample_cash_outlier==0 & sample==1 & treat_final==0, cl(employeenumber) ab(ym block_final) keepsing
est store col2
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "Control"
estadd local monthFE "YES"
estadd local stratumFE "YES"
estadd local individFE "NO"
estadd scalar adjR2 =  e(r2_a)

* Column 3
reghdfe cumbalance violence_34 if sample_cash_outlier==0 & sample==1 & treat_final==0, cl(employeenumber) ab(employeenumber ym) keepsing
est store col3
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "Control"
estadd local monthFE "YES"
estadd local stratumFE "-"
estadd local individFE "YES"
estadd scalar adjR2 =  e(r2_a)

* Column 4
reghdfe cash_savings violence_34 if sample_cash_outlier==0 & sample==1 & treat_final==0, cl(employeenumber) ab(ym) keepsing
est store col4
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "Control"
estadd local monthFE "YES"
estadd local stratumFE "NO"
estadd local individFE "NO"
estadd scalar adjR2 =  e(r2_a)

* Column 5
reghdfe cash_savings violence_34 if sample_cash_outlier==0 & sample==1 & treat_final==0, cl(employeenumber) ab(ym block_final) keepsing
est store col5
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "Control"
estadd local monthFE "YES"
estadd local stratumFE "YES"
estadd local individFE "NO"
estadd scalar adjR2 =  e(r2_a)

* Column 6
reghdfe cash_savings violence_34 if sample_cash_outlier==0 & sample==1 & treat_final==0, cl(employeenumber) ab(employeenumber ym) keepsing
est store col6
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "Control"
estadd local monthFE "YES"
estadd local stratumFE "-"
estadd local individFE "YES"
estadd scalar adjR2 =  e(r2_a)

esttab col1 col2 col3 col4 col5 col6 using "`output'/table_a13c.tex", cells(b(fmt(%9.2f) star) se(par fmt(%9.2f))) ///
starlevels(* .1 ** .05 *** .01) style(tex) keep(violence_34) ///
stats(samplestr in_sample_mean N_clust N adjR2 monthFE stratumFE individFE, fmt(0 2 0 0 2 0 0 0)  label("Sample" "Mean Dep Var" "\# Employees" "\# Observations" "R-Squared" "Month FE" "Strata FE" "Employee FE")) ///
label title("Experimental Dataset: Violence Expectations by Treatment Sample") replace 
